<template>
	<view class="control">
		<!-- <view class="top">
			<u--image width="100%"  src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/966faca491786134b9f2d5e5477aeb468829e5c1.png" mode="widthFix"></u--image>
		</view> -->

		<view class="list">
			<view @click="openDetail(item)" class="item flex-align" v-for="(item,index) in CoachList" :key="item">
				<view class="index">{{index+1}}</view>
				<image v-if="item.sex == 1" class="teacher-sex"
					src="https://sass-test.doit10019.com/upload/202505/16144421-05432478826173214.png?attname=%E7%94%B7.png"
					mode=""></image>
				<image v-if="item.sex == 2" class="teacher-sex"
					src="https://sass-test.doit10019.com/upload/202505/16144519-88180175334652816.png?attname=%E5%A5%B3.png"
					mode=""></image>
				<view class="flex-align con">
					<view class="image">
						<!-- <u--image  width="100%" height="130rpx" src="https://cdn.uviewui.com/uview/album/1.jpg" shape="circle"></u--image> -->
						<!-- <image :src="item.coach_avatar" style="width: 100rpx;height: 100rpx;border-radius: 50% 50%;"
							mode=""></image> -->
						<u-avatar :src="item.coach_avatar" shape="circle" :size="50"></u-avatar>
						<!-- <image mode="aspectFit" class="small" src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/c3d9ec46bec8cd3f02a5c9e0c2020af93119fa33.png"></image> -->
					</view>
					<view class="box">
						<view class="box-1 flex-align">
							<view class="name">{{item.full_name}}</view>
							<!-- <u-tag v-if="item.sex == 1" text="男" borderColor="#e5f0ff" bgColor="#e5f0ff" color="#016DFF"
								size="mini"> </u-tag>
							<u-tag v-if="item.sex == 2" text="女" borderColor="#e5f0ff" bgColor="#e5f0ff" color="#ff0000"
								size="mini"> </u-tag> -->
							<u-tag :text="'教学年龄：' + item.teach_age" borderColor="#016DFF" bgColor="#016DFF" color="#ffffff"
								size="mini"> </u-tag>
						</view>
						<view class="box-2 flex-align">
							<!-- <uni-rate :size="15" :max="5" :value="4"></uni-rate> -->
							<view class="tag">{{item.name || ''}}</view>
							<!-- <view class="tag">健身</view> -->
						</view>
						<view class="box-3">
							教学等级：{{item.level_type_name}}
						</view>
						<!-- <view class="box-4 flex-align">
							<u-icon :size="14" name="bag-fill"></u-icon>
							<view>{{item.level_type_name}}</view>
						</view> -->
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import uniRate from "@/uni_modules/uni-rate/components/uni-rate/uni-rate.vue"
	const index = require("@/api/index/index.js");
	export default {
		data() {
			return {
				venues_id: '',
				listQuery: { //分页
					pageNo: 1,
					pageSize: 14,
				},
				totalPage: '', //几页
				CoachList: []
			}
		},
		components: {
			uniRate
		},
		onLoad(options) {
			console.log(options,'options')
			this.venues_id = options.venues_id
			this.getCoachList()
		},
		methods: {
			async getCoachList() {
				let that = this;
				if (this.listQuery.pageNo === 1) that.CoachList = [];
				let data = {
					venue_id: this.venues_id,
					page: this.listQuery.pageNo,
					limit: this.listQuery.pageSize,
				};
				let result = await index.getCoachList(data);
				if (result.code == 1) {
					that.CoachList = that.CoachList.concat(result.data.list.data); //将数据拼接在一起
					that.totalPage = result.data.list.last_page
				}
			},
			// 下拉刷新
			onReachBottom() {
				if (this.totalPage <= this.listQuery.pageNo) {
					uni.showToast({
						title: '没有更多了',
						duration: 2000,
						icon: 'none'
					});
					return
				}
				this.listQuery.pageNo += 1;
				this.getCoachList()
			},
			openDetail(item) {
				uni.navigateTo({
					url: `./coachDetail?selectionArr=${encodeURIComponent(JSON.stringify(item))}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.teacher-sex {
		position: absolute;
		top: 10rpx;
		left: 150rpx;
		width: 30rpx;
		height: 30rpx;
		z-index: 99;
	}

	.control {
		width: 100%;
		min-height: 100vh;
		background-color: #ffffff;
		padding: 20rpx 30rpx 20rpx 30rpx;
		box-sizing: border-box;

		.top {
			/deep/ .u-image {
				height: auto !important;
			}
		}

		.list {
			.item {
				width: 100%;
				padding: 10px;
				background: #ffffff;
				box-shadow: 0px 3px 6px 1px rgba(23, 106, 180, 0.2);
				border-radius: 10px;
				margin: 10px 0;
				position: relative;

				&:nth-of-type(1) {
					.index {
						color: #016DFF;
					}
				}

				&:nth-of-type(2) {
					.index {
						color: #C0C0C0;
					}
				}

				&:nth-of-type(3) {
					.index {
						color: #B2786B;
					}
				}

				&:last-of-type {
					border: none;
				}

				.index {
					font-size: 36rpx;
					font-family: DIN;
					font-weight: bold;
					color: #95A0AF;
					margin-right: 40rpx;
				}

				.con {
					height: 100%;
					flex: 1;
					display: flex;
				}

				.image {
					width: 110rpx;
					height: 100%;
					// margin-right: 24rpx;
					position: relative;

					.small {
						width: 100%;
						height: 80rpx;
						position: absolute;
						bottom: -20rpx;
						left: 0;
					}
				}

				.box {
					flex: 1;
					width: 0;

					.box-1 {
						margin-bottom: 10rpx;

						.name {
							font-size: 28rpx;
							font-weight: bold;
							color: #333333;
						}

						/deep/ .u-tag {
							height: 40rpx;
							margin-left: 20rpx;

							.u-tag__text {
								font-size: 20rpx;
							}
						}
					}

					.box-2 {
						margin-bottom: 10rpx;

						.tag {
							font-size: 22rpx;
							font-weight: 400;
							color: #016DFF;
							// margin-left: 20rpx;
						}
					}

					.box-3 {
						font-size: 22rpx;
						font-weight: 400;
						color: #999999;
						white-space: nowrap;
						overflow: hidden;
						width: 100%;
						text-overflow: ellipsis;
					}

					.box-4 {
						font-size: 22rpx;
						font-weight: 500;
						color: #333333;
					}
				}

			}
		}
	}
</style>